<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="common/head::head"></head>
<body>

<div th:include="common/header::header"></div>

<div class="layui-container fly-marginTop">
  <div class="fly-panel" pad20 style="padding-top: 5px;">
    <div class="fly-none" th:if="${user == null}">没有权限,请登录</div>
    <div class="layui-form layui-form-pane" th:if="${user != null}">
      <div class="layui-tab layui-tab-brief" lay-filter="user">
        <ul class="layui-tab-title">
          <li class="layui-this">编辑帖子</li>
        </ul>
        <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;">
          <div class="layui-tab-item layui-show">
            <div class="layui-card" th:if="${log != null}">
              <div class="layui-card-header">老师点评</div>
              <div class="layui-card-body">
                <p th:text="${log?.content}" style="color: #FF7200;"></p>
              </div>
            </div>
            <form th:action="@{/posts/upd}" method="post">
              <div class="layui-row layui-col-space15 layui-form-item">
                <div class="layui-col-md3">
                  <label class="layui-form-label">所在专栏</label>
                  <div class="layui-input-block">
                    <select lay-verify="required" name="label" lay-filter="column">
                      <option th:each="label:${labels}" th:value="${label?.id}" th:text="${label?.name}" th:selected="${#strings.equals(label?.id, posts?.labelId)}"></option>
                    </select>
                  </div>
                </div>
                <div class="layui-col-md9">
                  <label for="L_title" class="layui-form-label">标题</label>
                  <div class="layui-input-block">
                    <input type="text" id="L_title" name="title" required lay-verify="required" autocomplete="off" class="layui-input" th:value="${posts?.title}">
                     <input type="hidden" name="jid" th:value="${posts?.id}">
                  </div>
                </div>
              </div>
              <div class="layui-form-item layui-form-text">
                <div class="layui-input-block">
                  <textarea id="L_content" name="content" required lay-verify="required" placeholder="详细描述" class="layui-textarea fly-editor" style="height: 260px;" th:text="${posts?.content}"></textarea>
                </div>
              </div>
              <div class="layui-form-item">
                <label for="L_vercode" class="layui-form-label">人类验证</label>
                <div class="layui-input-inline">
                  <input type="text" id="L_vercode" name="vercode" required lay-verify="required" placeholder="请输入后面内容" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid">
                  <img th:src="@{/captcha/code}" id="validateCode" title="看不清点击刷新" onclick="document.getElementById('validateCode').src= '/captcha/code?' + new Date().getTime();"/>
                </div>
              </div>
              <div class="layui-form-item">
                <button class="layui-btn" lay-filter="*" lay-submit>立即发布</button>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<div th:include="common/footer::footer"></div>

<script th:src="@{/layui/layui.js}"></script>
<script th:inline="javascript">
    layui.cache.page = 'jie';
    layui.cache.user = {
        username: [[${user==null?'游客':user.username}]]
        ,id: [[${user==null?-1:user.id}]]
    };
    layui.config({
        version: "3.0.0"
        ,base: '/mods/'
    }).extend({
        fly: 'index'
    }).use('fly');
</script>

</body>
</html>